export const heroImg = new Image()
export const soilImg = new Image()
export const stoneImg = new Image()

const images = []

const register = (img, src) => images.push({img, src})

export const load = async () => {
    register(heroImg, 'image/you.png')
    register(soilImg, 'image/soil.png')
    register(stoneImg, 'image/stone.png')

    let promises = images.map(e => new Promise(resolve => {
        e.img.src = e.src
        e.img.onload = () => resolve()
    })
  )

    await Promise.all(promises)
    console.log("all load")
}